package com.xh.shuati.config;
import com.volcengine.ark.runtime.service.ArkService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import okhttp3.Dispatcher;
import java.util.concurrent.TimeUnit;
import okhttp3.ConnectionPool;


/*
 * 火山引擎配置类
 */

@Configuration
@Data
public class AiConfig {
    @Value("${ai.apiKey}")
    private String apiKey;

    /***
     * Ai 请求客户端
     *
     * @return
     */
    @Bean
    public ArkService arkService() {
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder().dispatcher(dispatcher).connectionPool(connectionPool)
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                .apiKey(apiKey)
                .build();

        return service;
    }
}
